package com.tmeone.erpone.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tmeone.erpone.entity.JsonResult;
import com.tmeone.erpone.entity.WareAndProduct;
import com.tmeone.erpone.service.WareAndProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class WarningController {

    @Autowired
    private WareAndProductService wareAndProductService;

    @GetMapping("/warning/{current}/{pageSize}")
    public JsonResult findAllWarningProdut(@PathVariable(value = "current",required = false)Integer current, @PathVariable(value = "pageSize",required = false)Integer pageSize,@RequestParam(value = "wareNo",required = false) String wareNo,@RequestParam(value = "productName",required = false) String productName){
        Page<WareAndProduct> page = new Page<>(current, pageSize);
        IPage<WareAndProduct> wareAndProductIPage = wareAndProductService.wareAndProductPage(page,wareNo,productName);
        return new JsonResult(1,wareAndProductIPage);
    }

    @PutMapping("/warning")
    public void updateWarnNum(@RequestBody WareAndProduct wareAndProduct){
        System.out.println("金佛的时间佛和"+wareAndProduct);
        wareAndProductService.updateWarnNum(wareAndProduct);

    }

}
